package com.ruoyi.basicdata.service.impl;

import com.ruoyi.basicdata.domain.Building;
import com.ruoyi.basicdata.mapper.BuildingMapper;
import com.ruoyi.basicdata.mapper.ResidentMapper;
import com.ruoyi.basicdata.service.IBuildingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 楼栋管理Service业务层处理 git
 * 
 * @author ruoyi
 * @date 2023-04-05
 */
@Service
public class BuildingServiceImpl implements IBuildingService 
{
    @Autowired
    private BuildingMapper buildingMapper;

    @Autowired
    private ResidentMapper residentMapper;

    /**
     * 查询楼栋管理
     * 
     * @param id 楼栋管理主键
     * @return 楼栋管理
     */
    @Override
    public Building selectBuildingById(Long id)
    {
        return buildingMapper.selectBuildingById(id);
    }

    /**
     * 查询楼栋管理列表
     * 
     * @param building 楼栋管理
     * @return 楼栋管理
     */
    @Override
    public List<Building> selectBuildingList(Building building)
    {
        return buildingMapper.selectBuildingList(building);
    }

    /**
     * 新增楼栋管理
     * 
     * @param building 楼栋管理
     * @return 结果
     */
    @Override
    public int insertBuilding(Building building)
    {
        return buildingMapper.insertBuilding(building);
    }

    /**
     * 修改楼栋管理
     * 
     * @param building 楼栋管理
     * @return 结果
     */
    @Override
    public int updateBuilding(Building building)
    {
        return buildingMapper.updateBuilding(building);
    }

    /**
     * 批量删除楼栋管理
     * 
     * @param ids 需要删除的楼栋管理主键
     * @return 结果
     */
    @Override
    public int deleteBuildingByIds(Long[] ids){
        residentMapper.deleteResidentByBuildingIds(ids);
        return buildingMapper.deleteBuildingByIds(ids);
    }

    /**
     * 删除楼栋管理信息
     * 
     * @param id 楼栋管理主键
     * @return 结果
     */
    @Override
    public int deleteBuildingById(Long id){
        residentMapper.deleteResidentByBuildingId(id);
        return buildingMapper.deleteBuildingById(id);
    }

    @Override
    public int changeState(Long id) {
        buildingMapper.changeState(id);
        return 0;
    }

    @Override
    public int taskChangeState(List<Long> ids) {
        return buildingMapper.taskChangeState(ids);
    }
}
